

/*
Download and process unemployment data from FRED
*/

freduse UNRATE, clear
gen datem = mofd(daten)
format datem %tm

gen year = year(daten)

collapse (mean) UNRATE, by(year)

keep year UNRATE
order year UNRATE

save temp_UNRATE.dta, replace

/*
Process data from GOS
Spreadsheet can be downloaded from Fatih Guvenen's website
Ordering:
1. Year (t)
2. Std 1year
3. Std 5year
4. Skewness 1year
5. Skewness 5year
Data is for t-k to t
*/

import excel "gos-jpe2014-data.xlsx", sheet("Figure 4") cellrange(A5:E37) clear
rename A year
rename B std_1y
rename C std_5y
rename D skew_1y
rename E skew_5y

gen mu3_1y = skew_1y*(std_1y^3)
gen mu3_5y = skew_5y*(std_5y^3)

/*
Merge unrate with mu3
*/

merge 1:1 year using temp_UNRATE.dta
drop _merge 

sort year

tsset year

// define dU
gen dU_1y = UNRATE - L.UNRATE
gen dU_5y = UNRATE - L5.UNRATE

keep year mu3* dU*
order year mu3* dU*

keep if !mi(mu3_1y) | !mi(mu3_5y)


/*
Save 
*/

export excel using "plot_data.xlsx", firstrow(var) replace

// clean up
rm temp_UNRATE.dta